/**
 * Project: saasoa
 * Copyright 2013  Top Digital Technology  Co. Ltd.
 * All right reserved.
 */
package com.topdt.jbpm.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * 建立日期 : 2013-6-24 上午11:06:26<br>
 * 作者 : balance<br>
 * 模块 : <br>
 * 描述 : <br>
 * 修改历史: 序号 日期 修改人 修改原因 <br>
 * 1 <br>
 * 2 <br>
 */
@Entity
@Table(name = "wf_activity")
public class Activity extends JbpmModel {

	private static final long serialVersionUID = -8712600742001803785L;

	/**
	 * 通过已处理环节处理人的关系定义
	 */
	public static final String MODEL_RELATIVE = "relative";

	/**
	 * 通过指定部门、角色、人员方式定义
	 */
	public static final String MODEL_ABSOLUTE = "absolute";

	/**
	 * 任务多人执行规则：并行
	 */
	public static final String DO_CONCURRENCE = "concurrence";

	/**
	 * 任务多人执行规则：顺序
	 */
	public static final String DO_SEQUENCE = "sequence";

	/**
	 * 任务多人执行规则：唯一
	 */
	public static final String DO_UNIQUE = "unique";

	@Id
	@GeneratedValue(generator = "generator")
	@GenericGenerator(name = "generator", strategy = "uuid")
	@Column(length = 32)
	private String activityId;
	private String flowId;
	private String flowKey;
	private String activityName;// 活动名称

	@Column(name = "ACTOR_NUM")
	private int actorNUM;// 规定实际参与人数，用于和候选人数比较，若候选人数多于规定的参与人数，则需要人工指定执行人

	private String doRule;// 多人执行任务的顺序，0：无须，1：顺序，2：唯一
	private String assignerActivity;// 指定本活动人员的位置
	private String assignmentParamKey;
	private String actorModel = MODEL_ABSOLUTE;// 定义模式:relative（通过已处理环节处理人的关系定义）|absolute（通过指定部门、角色、人员方式定义）;

	private boolean backable;// 可返还上一环节
	private boolean restartable;// 可返还第一个环节

	@Column(name = "SEQ_NUM")
	private int seqNUM;

	@OneToMany(mappedBy = "activityId", fetch = FetchType.LAZY)
	private List<ActorDefinDetail> details;

	private String flowDetailId;
	
	//add by calonlan 分支条件
	@Column(name = "branch_condition")
	private String desc;
	
	public String getActivityId() {
		return activityId;
	}

	public void setActivityId(String activityId) {
		this.activityId = activityId;
	}

	public int getSeqNUM() {
		return seqNUM;
	}

	public void setSeqNUM(int seqNUM) {
		this.seqNUM = seqNUM;
	}

	public String getFlowKey() {
		return flowKey;
	}

	public void setFlowKey(String flowKey) {
		this.flowKey = flowKey;
	}

	public String getFlowId() {
		return flowId;
	}

	public void setFlowId(String flowId) {
		this.flowId = flowId;
	}

	public boolean isRelativeModel() {
		return this.actorModel.equals(MODEL_RELATIVE);
	}

	public boolean isAbsoluteModel() {
		return this.actorModel.equals(MODEL_ABSOLUTE);
	}

	public String getActorModel() {
		return actorModel;
	}

	public void setActorModel(String actorModel) {
		this.actorModel = actorModel;
	}

	public String getActivityName() {
		return activityName;
	}

	public void setActivityName(String activityName) {
		this.activityName = activityName;
	}

	public int getActorNUM() {
		return actorNUM;
	}

	public void setActorNUM(int actorNUM) {
		this.actorNUM = actorNUM;
	}

	public String getDoRule() {
		return doRule;
	}

	public void setDoRule(String doRule) {
		this.doRule = doRule;
	}

	public String getAssignerActivity() {
		return assignerActivity;
	}

	public void setAssignerActivity(String assignerActivity) {
		this.assignerActivity = assignerActivity;
	}

	public String getAssignmentParamKey() {
		return assignmentParamKey;
	}

	public void setAssignmentParamKey(String assignmentParamKey) {
		this.assignmentParamKey = assignmentParamKey;
	}

	public List<ActorDefinDetail> getDetails() {
		return details;
	}

	public void setDetails(List<ActorDefinDetail> details) {
		this.details = details;
	}

	public String getFlowDetailId() {
		return flowDetailId;
	}

	public void setFlowDetailId(String flowDetailId) {
		this.flowDetailId = flowDetailId;
	}

	public boolean isBackable() {
		return backable;
	}

	public void setBackable(boolean backable) {
		this.backable = backable;
	}

	public boolean isRestartable() {
		return restartable;
	}

	public void setRestartable(boolean restartable) {
		this.restartable = restartable;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

}
